﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
        <div class="w_980">
	<!--back_box-->
	<div class="back_box clearfix">
    	<% 
            Html.RenderPartial("~/Views/Shared/VipCenterList.ascx");
    //ViewData["list"]
        %>
    	<!--right-->
        <div class="back_main">
        	<h3><%=ViewData["name"]%></h3>
            <div class="my_love">
            	<!--top_bar-->
            	<div class="love_bar">
                	<p class="love_bar_left"><input name="allchoose" type="checkbox" value="" />全选<a href="#" name="del" title="删除">删除</a></p>
                	<p class="back_pager"></p>
                </div>
                <!--list-->
                <%
                int pageno = Request["pageno"] == null ? 1 : int.Parse(Request["pageno"].ToString());//当前页
                int pagesize = 15;//单页记录数
                int count = 0;//总记录数
                int pageNumber = 0;//总页数
                IList list = (IList)ViewData["list"];        
                %>   
            	<ul class="my_love_ul">
                	<!--1-->
                       <%
                        foreach (Hashtable tb in list)
                        {
                            if (tb["total"] == null)
                            {
                                Response.Write("<li>");
                                Response.Write("<input name=\"alllistchoose\" type=\"checkbox\" value=\"" + tb["us_id"] + "\" />");
                                Response.Write("<div class=\"love_book_img\"><a href=\"/search/detail.html?id="+tb["lb_id"]+"\"><img src=\"../../images/book_03.jpg\" /></a></div>");
                                Response.Write("<dl>");
                                Response.Write("<dt><a href=\"/search/detail.html?id="+tb["lb_id"]+"\">" + tb["lb_bookName"] + "</a></dt>");
                                Response.Write("<dd class=\"dd_color\">年龄：" + Enum.GetName(typeof(DAL.Enums.bookforAge), int.Parse(tb["lb_forAge"].ToString())).ToString().Replace("_", "") + "</dd>");
                                Response.Write("<dd>作者：" + tb["lb_author"] + "</dd>");
                                Response.Write("<dd>出版社：" + tb["lb_press"] + "</dd>");
                                Response.Write("<dd></dd>");
                                Response.Write("</dl>");
                                Response.Write(" <div class=\"lov_del_box\"><a href=\"#\" onclick=\"del(" + tb["us_id"] + ");\" >删除</a></div>");
                                Response.Write("</li>");
                            }
                            else
                                count = (tb["total"] == null ? 0 : int.Parse(tb["total"].ToString()));
                        }
                        %>
                </ul>

            	<!--bottom_bar-->
            	<div class="love_bar">
                	<p class="love_bar_left"><input name="allchoose" type="checkbox" value="" />全选<a href="javascript:void(0);" name="del" title="删除">删除</a></p>
                </div>
            </div>
             <div class="pager">
                <%
                    pageNumber = ((count % pagesize) == 0 ? (count / pagesize) : ((count / pagesize) + 1));
                    int start = pagesize * (pageno - 1) + 1;
                    if (start < 0)
                        start = 0;
                    int end = (start + pagesize-1);
                    if (pageno == pageNumber)
                    {
                        if ((count % pagesize) != 0)
                        {
                            end = (start + (count % pagesize) - 1);
                        }
                    }
                %>
                <p class="left"><%=count%> 条记录，显示第 <%=start %> 条 - 第 <%=end %> 条记录</p>
                <p class="right"><a href="<%=Request.RawUrl %>&pageno=1" title="首页" class="a1 a1_n"></a>
                <a href="<%=Request.RawUrl %>&pageno=<%=(pageno==1?1:pageno-1) %>" title="上一页" class="a2"></a><span>第<b><%=pageno %></b>页/共 <%=pageNumber %> 页</span>
                <a href="<%=Request.RawUrl %>&pageno=<%=(pageno==pageNumber?pageNumber:pageno+1) %>" title="下一页" class="a3"></a><a href="<%=Request.RawUrl %>&pageno=<%=pageNumber %>" title="末页" class="a4"></a>
                <select id="sPage">
                <% 
                    for (int k = 1; k <= pageNumber;k++ )
                        Response.Write("<option value=\"" + k.ToString() + "\">" + k.ToString() + "</option>");
                %>
                </select></p>
                <script type="text/javascript" language="javascript">
                    $(function () {
                        $("#sPage").val(<%=pageno %>);
                        $("#sPage").change(function () {
                            window.location.href = "/Vipcenter/dlist.html?pageno=" + $("#sPage").val();
                        });
                    })
                </script>
            </div>
        </div>
    </div>
</div>
<!--copyright-->
<script type="text/javascript">
    $(document).ready(function () {
        $("[name='allchoose']").click(function () {
            if ($(this).attr("checked") == "checked") {
                $("[name='allchoose']").attr("checked", 'true'); //全选 
                $("[name='alllistchoose']").attr("checked", $(this).attr("checked")); //全选
            }
            else {
                $("[name='allchoose']").removeAttr("checked"); //全取消
                $("[name='alllistchoose']").removeAttr("checked"); //全取消
            }

        });
        $("[name='del']").click(function () {
            if (confirm("此操作将删除所选内容")) {
                var delstr = "";
                $("[name='alllistchoose']").each(function () {
                    if ($(this).attr("checked") == "checked") {
                        delstr = delstr + $(this).val() + ",";
                    }
                });
                delstr = delstr.substring(0, delstr.length - 1);
                $.post("/Vipcenter/delUserSave.html", { ids: delstr }, function (dta) {
                    alert("删除成功");
                    window.location.reload();
                });
            }
        });
    });
    function del(id) {
        $.post("/Vipcenter/delUserSave.html", { ids: id }, function (dta) {
            alert("删除成功");
            window.location.reload();
        });
    }
</script>

</asp:Content>
